using System;
using AntEater.ComponentModel.Validation;
using System.ComponentModel;
using System.Collections.ObjectModel;
using AntEater.ComponentModel.BuildElements.Design;
using System.Drawing.Design;

namespace AntEater.ComponentModel.BuildElements
{
    /// <summary>
    /// Provides an build element for XML Comment.
    /// </summary>
    [Serializable]
    [BuildElement("Comment")]
    [Icon(typeof(CommentBuildElement), "AntEater.ComponentModel.Resources.XMLComment.ico")]
    public class CommentBuildElement : BuildElementBase
    {

        /// <summary>
        /// Initializes a new instance of the <see cref="T:CommentBuildElement"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        public CommentBuildElement(BuildFileDefinition context)
            : base(context) {
        }

        private string _text;

        /// <summary>
        /// Gets or sets the text.
        /// </summary>
        /// <value>The text.</value>
        [BuildElementProperty("Text", false, BuildElementPropertyType.String)]
        [Editor(typeof(TextTypeEditor),typeof(UITypeEditor))]
        [TypeConverter(typeof(TextConverter))]
        [Description("The text between the <!-- --> tags.")]
        [Category("MsBuild")]
        [ToolTip()]
        public string Text {
            get { return _text; }
            set {
                if (_text != value) {
                    _text = value;
                    OnPropertyChanged("Text");
                }
            }
        }

        /// <summary>
        /// Determines whether this instance is valid.
        /// </summary>
        /// <value></value>
        /// <returns>
        /// 	<c>true</c> if this instance is valid; otherwise, <c>false</c>.
        /// </returns>
        public override bool IsValid {
            get { throw new NotImplementedException(); }
        }

        /// <summary>
        /// Validates the specified recursive.
        /// </summary>
        /// <param name="recursive">if set to <c>true</c> [recursive].</param>
        /// <returns></returns>
        public override ReadOnlyCollection<ValidationResult> Validate(bool recursive) {
            throw new NotImplementedException();
        }


        /// <summary>
        /// Creates a new object that is a copy of the current instance.
        /// </summary>
        /// <returns>
        /// A new object that is a copy of this instance.
        /// </returns>
        public override object Clone() {
            CommentBuildElement newElement = base.Clone() as CommentBuildElement;

            if (this._text != null) {
                newElement._text = this._text.Clone() as string;
            }

            return newElement;
        }
    }
}
